import pandas as pd
import numpy as np


# date_range
date_range = pd.date_range('2018-10-11', periods=6)
print(date_range)

# data_frame
print("====================================")
frame = pd.DataFrame(np.random.rand(6, 4), index=date_range, columns=list('ABCD'))
print(frame)

categorical = pd.Categorical(["test", "train", "test", "train","test", "train", "test", "train",])
# print(categorical)
df2 = pd.DataFrame({'A': 1., 'B': categorical})
print(df2)
print("======")
print(df2.dtypes)


print("===")
print(df2.A)

# 用head和tail查看顶端和低端的几列
print("=======")
print(df2)
print("--------")
# head = df2.head()
# print(head)
# print(df2.tail(2))
# print(df2.index)
# print(df2.values)
# print(df2.describe())
# print(df2.T)
# print(df2.sort_index(axis=1, ascending=True))
# print(df2['B'])
# print(type(df2['B']))
print(df2.apply(np.cumsum))
# print(df2.apply(lambda x:x.max() - x.min()))

